import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    txt1: '注册',
    txt2:'注册', 
    // username:'请登录',
    // uid:null,
    // userimg:'/user.jpeg',
    username:sessionStorage.getItem('username'),
    uid:sessionStorage.getItem('uid'),
    userimg:sessionStorage.getItem('userimg'),
    idphone:sessionStorage.getItem('idphone'),
    islogin:sessionStorage.getItem('islogin'),

  },
  getters: {
  },
  mutations: {

    passwordset(state, payload) {
      state.txt1 = payload
    },
    txtset(state, payload) {
      state.txt2 = payload
    },
    updataName(state, payload){
      state.username = payload
      sessionStorage.setItem('username',payload)

    },
    getUid(state, payload){
      state.uid = payload
      sessionStorage.setItem('uid',payload)
    },
    userImg(state, payload){
      state.userimg = payload
      sessionStorage.setItem('userimg',payload)
    },
    loginOK(state, payload){
      state.islogin = true
      state.idphone = payload
      sessionStorage.setItem('islogin',true)
      sessionStorage.setItem('idphone',payload)
    },
    signOut(state, payload){
      state.islogin = false
      sessionStorage.setItem('islogin',false)

      sessionStorage.setItem('username',payload)
      sessionStorage.setItem('uid',payload)
      sessionStorage.setItem('userimg',payload)
      sessionStorage.setItem('idphone',payload)
      
    }

  },
  actions: {
  },
  modules: {
  }
})
